<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Eigen: Eigen::Map&lt; PlainObjectType, MapOptions, StrideType &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="eigendoxy.css" rel="stylesheet" type="text/css">
<!--  -->
<script type="text/javascript" src="eigen_navtree_hacks.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="Eigen_Silly_Professor_64x64.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="http://eigen.tuxfamily.org">Eigen</a>
   &#160;<span id="projectnumber">3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)</span>
   </div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.svg"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classEigen_1_1Map.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="classEigen_1_1Map-members.html">List of all members</a> &#124;
<a href="#pub-methods">Public Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">Eigen::Map&lt; PlainObjectType, MapOptions, StrideType &gt; Class Template Reference<div class="ingroups"><a class="el" href="group__DenseMatrixManipulation__chapter.html">Dense matrix and array manipulation</a> &raquo; <a class="el" href="group__DenseMatrixManipulation__Reference.html">Reference</a> &raquo; <a class="el" href="group__Core__Module.html">Core module</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename PlainObjectType, int MapOptions, typename StrideType&gt;<br />
class Eigen::Map&lt; PlainObjectType, MapOptions, StrideType &gt;</h3>

<p>A matrix or vector expression mapping an existing array of data. </p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">PlainObjectType</td><td>the equivalent matrix type of the mapped data </td></tr>
    <tr><td class="paramname">MapOptions</td><td>specifies the pointer alignment in bytes. It can be: <code><a class="el" href="group__enums.html#gga45fe06e29902b7a2773de05ba27b47a1a60057da2408e499b5656244d0b26cc20">Aligned128</a></code>, <code><a class="el" href="group__enums.html#gga45fe06e29902b7a2773de05ba27b47a1a2639cfa1e8faac751556bc0009fe95a4">Aligned64</a></code>, <code><a class="el" href="group__enums.html#gga45fe06e29902b7a2773de05ba27b47a1a8a380b1cd0c3e5a6cceac06f8235157a">Aligned32</a></code>, <code><a class="el" href="group__enums.html#gga45fe06e29902b7a2773de05ba27b47a1ad0b140cd97bc74365b51843d28379655">Aligned16</a></code>, <code><a class="el" href="group__enums.html#gga45fe06e29902b7a2773de05ba27b47a1a9d99d7a9ff1da5c949bec22733bfba14">Aligned8</a></code> or <code><a class="el" href="group__enums.html#gga45fe06e29902b7a2773de05ba27b47a1a4e19dd09d5ff42295ba1d72d12a46686">Unaligned</a></code>. The default is <code><a class="el" href="group__enums.html#gga45fe06e29902b7a2773de05ba27b47a1a4e19dd09d5ff42295ba1d72d12a46686">Unaligned</a></code>. </td></tr>
    <tr><td class="paramname">StrideType</td><td>optionally specifies strides. By default, <a class="el" href="classEigen_1_1Map.html" title="A matrix or vector expression mapping an existing array of data.">Map</a> assumes the memory layout of an ordinary, contiguous array. This can be overridden by specifying strides. The type passed here must be a specialization of the <a class="el" href="classEigen_1_1Stride.html" title="Holds strides information for Map.">Stride</a> template, see examples below.</td></tr>
  </table>
  </dd>
</dl>
<p>This class represents a matrix or vector expression mapping an existing array of data. It can be used to let <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> interface without any overhead with non-Eigen data structures, such as plain C arrays or structures from other libraries. By default, it assumes that the data is laid out contiguously in memory. You can however override this by explicitly specifying inner and outer strides.</p>
<p>Here's an example of simply mapping a contiguous array as a <a class="el" href="group__TopicStorageOrders.html">column-major</a> matrix: </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> array[9];</div>
<div class="line"><span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0; i &lt; 9; ++i) array[i] = i;</div>
<div class="line">cout &lt;&lt; Map&lt;Matrix3i&gt;(array) &lt;&lt; endl;</div>
</div><!-- fragment --><p> Output: </p><pre class="fragment">0 3 6
1 4 7
2 5 8
</pre><p>If you need to map non-contiguous arrays, you can do so by specifying strides:</p>
<p>Here's an example of mapping an array as a vector, specifying an inner stride, that is, the pointer increment between two consecutive coefficients. Here, we're specifying the inner stride as a compile-time fixed value. </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> array[12];</div>
<div class="line"><span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0; i &lt; 12; ++i) array[i] = i;</div>
<div class="line">cout &lt;&lt; Map&lt;VectorXi, 0, InnerStride&lt;2&gt; &gt;</div>
<div class="line">         (array, 6) <span class="comment">// the inner stride has already been passed as template parameter</span></div>
<div class="line">     &lt;&lt; endl;</div>
</div><!-- fragment --><p> Output: </p><pre class="fragment"> 0
 2
 4
 6
 8
10
</pre><p>Here's an example of mapping an array while specifying an outer stride. Here, since we're mapping as a column-major matrix, 'outer stride' means the pointer increment between two consecutive columns. Here, we're specifying the outer stride as a runtime parameter. Note that here <code>OuterStride&lt;&gt;</code> is a short version of <code>OuterStride&lt;Dynamic&gt;</code> because the default template parameter of <a class="el" href="classEigen_1_1OuterStride.html" title="Convenience specialization of Stride to specify only an outer stride See class Map for some examples.">OuterStride</a> is <code>Dynamic</code> </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> array[12];</div>
<div class="line"><span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0; i &lt; 12; ++i) array[i] = i;</div>
<div class="line">cout &lt;&lt; Map&lt;MatrixXi, 0, OuterStride&lt;&gt; &gt;(array, 3, 3, OuterStride&lt;&gt;(4)) &lt;&lt; endl;</div>
</div><!-- fragment --><p> Output: </p><pre class="fragment"> 0  4  8
 1  5  9
 2  6 10
</pre><p>For more details and for an example of specifying both an inner and an outer stride, see class <a class="el" href="classEigen_1_1Stride.html" title="Holds strides information for Map.">Stride</a>.</p>
<p><b>Tip:</b> to change the array of data mapped by a <a class="el" href="classEigen_1_1Map.html" title="A matrix or vector expression mapping an existing array of data.">Map</a> object, you can use the C++ placement new syntax:</p>
<p>Example: </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> data[] = {1,2,3,4,5,6,7,8,9};</div>
<div class="line">Map&lt;RowVectorXi&gt; v(data,4);</div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;The mapped vector v is: &quot;</span> &lt;&lt; v &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><span class="keyword">new</span> (&amp;v) Map&lt;RowVectorXi&gt;(data+4,5);</div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;Now v is: &quot;</span> &lt;&lt; v &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
</div><!-- fragment --><p> Output: </p><pre class="fragment">The mapped vector v is: 1 2 3 4
Now v is: 5 6 7 8 9
</pre><p>This class is the return type of <a class="el" href="classEigen_1_1PlainObjectBase.html#aaf9fcc07dc13f89cf71d4a4e2b220d24">PlainObjectBase::Map()</a> but can also be used directly.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classEigen_1_1PlainObjectBase.html#aaf9fcc07dc13f89cf71d4a4e2b220d24">PlainObjectBase::Map()</a>, <a class="el" href="group__TopicStorageOrders.html">Storage orders</a> </dd></dl>
</div>
<p>Inherits MapBase&lt; Map&lt; PlainObjectType, MapOptions, StrideType &gt; &gt;.</p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a43b3e84aba2ff1a241dbc3d177fb2e22"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1Map.html#a43b3e84aba2ff1a241dbc3d177fb2e22">Map</a> (PointerArgType dataPtr, const StrideType &amp;stride=StrideType())</td></tr>
<tr class="separator:a43b3e84aba2ff1a241dbc3d177fb2e22"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3f621386d55a373f53082ac62579897e"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1Map.html#a3f621386d55a373f53082ac62579897e">Map</a> (PointerArgType dataPtr, <a class="el" href="namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Index</a> rows, <a class="el" href="namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Index</a> cols, const StrideType &amp;stride=StrideType())</td></tr>
<tr class="separator:a3f621386d55a373f53082ac62579897e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a52069afac76e3f609a6865106dc10254"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classEigen_1_1Map.html#a52069afac76e3f609a6865106dc10254">Map</a> (PointerArgType dataPtr, <a class="el" href="namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Index</a> size, const StrideType &amp;stride=StrideType())</td></tr>
<tr class="separator:a52069afac76e3f609a6865106dc10254"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a43b3e84aba2ff1a241dbc3d177fb2e22"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a43b3e84aba2ff1a241dbc3d177fb2e22">&#9670;&nbsp;</a></span>Map() <span class="overload">[1/3]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename PlainObjectType , int MapOptions, typename StrideType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classEigen_1_1Map.html">Eigen::Map</a>&lt; PlainObjectType, MapOptions, StrideType &gt;::<a class="el" href="classEigen_1_1Map.html">Map</a> </td>
          <td>(</td>
          <td class="paramtype">PointerArgType&#160;</td>
          <td class="paramname"><em>dataPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const StrideType &amp;&#160;</td>
          <td class="paramname"><em>stride</em> = <code>StrideType()</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">explicit</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Constructor in the fixed-size case.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">dataPtr</td><td>pointer to the array to map </td></tr>
    <tr><td class="paramname">stride</td><td>optional <a class="el" href="classEigen_1_1Stride.html" title="Holds strides information for Map.">Stride</a> object, passing the strides. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a52069afac76e3f609a6865106dc10254"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a52069afac76e3f609a6865106dc10254">&#9670;&nbsp;</a></span>Map() <span class="overload">[2/3]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename PlainObjectType , int MapOptions, typename StrideType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classEigen_1_1Map.html">Eigen::Map</a>&lt; PlainObjectType, MapOptions, StrideType &gt;::<a class="el" href="classEigen_1_1Map.html">Map</a> </td>
          <td>(</td>
          <td class="paramtype">PointerArgType&#160;</td>
          <td class="paramname"><em>dataPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Index</a>&#160;</td>
          <td class="paramname"><em>size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const StrideType &amp;&#160;</td>
          <td class="paramname"><em>stride</em> = <code>StrideType()</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Constructor in the dynamic-size vector case.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">dataPtr</td><td>pointer to the array to map </td></tr>
    <tr><td class="paramname">size</td><td>the size of the vector expression </td></tr>
    <tr><td class="paramname">stride</td><td>optional <a class="el" href="classEigen_1_1Stride.html" title="Holds strides information for Map.">Stride</a> object, passing the strides. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a3f621386d55a373f53082ac62579897e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3f621386d55a373f53082ac62579897e">&#9670;&nbsp;</a></span>Map() <span class="overload">[3/3]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename PlainObjectType , int MapOptions, typename StrideType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classEigen_1_1Map.html">Eigen::Map</a>&lt; PlainObjectType, MapOptions, StrideType &gt;::<a class="el" href="classEigen_1_1Map.html">Map</a> </td>
          <td>(</td>
          <td class="paramtype">PointerArgType&#160;</td>
          <td class="paramname"><em>dataPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Index</a>&#160;</td>
          <td class="paramname"><em>rows</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Index</a>&#160;</td>
          <td class="paramname"><em>cols</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const StrideType &amp;&#160;</td>
          <td class="paramname"><em>stride</em> = <code>StrideType()</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Constructor in the dynamic-size matrix case.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">dataPtr</td><td>pointer to the array to map </td></tr>
    <tr><td class="paramname">rows</td><td>the number of rows of the matrix expression </td></tr>
    <tr><td class="paramname">cols</td><td>the number of columns of the matrix expression </td></tr>
    <tr><td class="paramname">stride</td><td>optional <a class="el" href="classEigen_1_1Stride.html" title="Holds strides information for Map.">Stride</a> object, passing the strides. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="Map_8h_source.html">Map.h</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="namespaceEigen.html">Eigen</a></li><li class="navelem"><a class="el" href="classEigen_1_1Map.html">Map</a></li>
    <li class="footer">Generated on Thu Apr 21 2022 13:07:56 for Eigen by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
